/*------------------------------------------------------------------------
//                          Project CommonLib                           //
------------------------------------------------------------------------*/


#pragma once


namespace Algorithm
{
	typedef int (*QSortCB)(const void *a, const void *b);

		void QSort(void *base, unsigned int num, unsigned int size, QSortCB callback);

	template<typename T>
	int SortDescendT(const void *a,const void *b)
	{
		return (int)(*(T*)b - *(T*)a);
	}

	template<typename T>
	int SortAscendT(const void *a,const void *b)
	{
		return (int)(*(T*)a - *(T*)b);
	}

	template<>
		int SortDescendT<float>(const void *a,const void *b);
}


#define QSORT_DES(base, num, TYPE) Algorithm::QSort(base, num, sizeof(TYPE), CommonLib::Algorithm::SortDescendT<TYPE>);
#define QSORT_ASC(base, num, TYPE) Algorithm::QSort(base, num, sizeof(TYPE), CommonLib::Algorithm::SortAscendT<TYPE>);
/*------------------------------------------------------------------------

------------------------------------------------------------------------*/
